﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PathFinding
{
	public class BasicIntersection : IIntersection
	{
		#region Constructor
		public BasicIntersection(int x, int y)
		{
			X = x;
			Y = y;
			Weight = 0;
			IsCalculated = false;
			Neighbours = new IIntersection[] { };
		}
		#endregion

		#region IIntersection Members

		public string LocationName { get; set; }

		public int X { get; set; }

		public int Y { get; set; }

		public double Weight { get; set; }

		public bool IsCalculated { get; set; }

		public IIntersection[] Neighbours { get; set; }

		public double GetDistance(IIntersection destination)
		{
			decimal divX = Math.Abs(X - destination.X);
			decimal divY = Math.Abs(Y - destination.Y);

			return Math.Sqrt(Math.Pow(Convert.ToDouble(divX), 2) + Math.Pow(Convert.ToDouble(divY), 2));
		}

		public IIntersection PreviousNode { get; set; }

		#endregion
	}
}
